﻿//-----------------------------------------------------------------------
// <copyright file="AudioFrameParser.cs" company="Andrew Oakley">
//     Copyright (c) 2010 Andrew Oakley
//     This program is free software: you can redistribute it and/or modify
//     it under the terms of the GNU Lesser General Public License as published by
//     the Free Software Foundation, either version 3 of the License, or
//     (at your option) any later version.
//
//     This program is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU Lesser General Public License for more details.
//
//     You should have received a copy of the GNU Lesser General Public License
//     along with this program.  If not, see http://www.gnu.org/licenses.
// </copyright>
//-----------------------------------------------------------------------

namespace Silverlight.Media.Parsers
{
    /// <summary>
    /// Base class for all audio frame parsers.
    /// </summary>
    public abstract class AudioFrameParser
    {
        /// <summary>
        /// Initializes a new instance of the AudioFrameParser class.
        /// </summary>
        protected AudioFrameParser()
        {
        }

        /// <summary>
        /// Gets or sets the size of the audio frame header.
        /// </summary>
        public int FrameHeaderSize { get; protected set; }

        /// <summary>
        /// Gets or sets the frame header synchronization bits.
        /// </summary>
        public byte[] SyncBytes { get; protected set; }

        /// <summary>
        /// Checks the supplied bytes to verify is a valid audio frame.
        /// </summary>
        /// <param name="audioFrameHeader">Bytes representing an audio frame header.</param>
        /// <returns>True if the supplied audio frame header is valid, otherwise, false.</returns>
        public abstract bool IsValidFrame(byte[] audioFrameHeader);

        /// <summary>
        /// Creates an AudioFrame from the supplied audio frame header bytes.
        /// </summary>
        /// <param name="audioFrameHeader">Bytes representing an audio frame header.</param>
        /// <returns>Instance of an AudioFrame.</returns>
        public abstract AudioFrame CreateFrame(byte[] audioFrameHeader);

        /// <summary>
        /// Creates a WaveFormat based on the supplied AudioFrame.
        /// </summary>
        /// <param name="audioFrame">An AudioFrame instance used to create the WaveFormat.</param>
        /// <returns>Instance of a WaveFormat.</returns>
        public abstract WaveFormat CreateWaveFormat(AudioFrame audioFrame);
    }
}
